home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / PAS_0793 / NEWQWRIT.PAS < prev    next >
Pascal/Delphi Source File  |  1993-08-01  |  2KB  |  47 lines

  1. {─ Fido Pascal Conference ────────────────────────────────────────────── PASCAL ─
  2. Msg  : 82 of 109                                                                
  3. From : Jon Taylor                          1:363/640.0          29 Jun 93  12:34 
  4. To   : Lou Duchez                          1:157/200.0                           
  5. Subj : Timers                                                                 
  6. ────────────────────────────────────────────────────────────────────────────────
  7. * In a message originally to John Linden, Lou Duchez said:
  8.  
  9.  > BO>JL>How do you put a timer that changes every second on the screen
  10.  > without movin
  11.  > BO>JL>the cursor all the tim. For instance, I am writing a terminal and
  12.  
  13.  > My two cents: if you want to do direct video writes, here's
  14.  > my contribution;
  15.  
  16. And I'll add my two cents--The routine looks good but it (like alot of "quick
  17. write" routines) assumes an 80 column display.  I have a 132 column display--so
  18. I modified your routine to dynamically adjust to the width of the
  19. screen:}
  20. procedure qwrite(x, y: byte; s: string; f, b: byte);
  21.  
  22.   type  videolocation = record    { the layout of a two-byte vidcell }       
  23. videodata: char;        { character displayed }
  24.         videoattribute: byte;   { attributes }
  25.         end;
  26.  
  27. var cnter: byte;
  28.     videosegment: word;         { the location of video memory }
  29.     monosystem: boolean;        { mono vs. color }
  30.     vidptr: ^videolocation;     { pointer to video locations }
  31.     cols: byte;                 { Number of columns! }
  32.  begin 
  33.    monosystem := (lastmode in [0,2,7]);
  34.    if monosystem then videosegment := $b000 else videosegment := $b800;
  35.    ASM mov ah, 0fh; int 10h; mov cols, ah; END; { Get # of cols! }   vidptr := 
  36. ptr(videosegment, 2*(cols*(y - 1) + (x - 1))); {Note cols!}   for cnter := 1 to
  37. length(s) do begin
  38.      vidptr^.videoattribute := (b shl 4) + f; { high nibble=bg; lo nibble=fg }
  39.      vidptr^.videodata := s[cnter];            { put character at location }
  40.      inc(vidptr);                              { go to next video location }
  41.      end;
  42.    end;
  43.  
  44. I know most people don't have displays with more than 80 columns, but the
  45. modification is easy when done this way (but not so easy when you use the
  46. MEM/MEMW approach to video memory, or define a big RECORD for all of video
  47. memory).